<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>出险管理</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <link rel="icon" href="/static/images/favicon.ico">
    <link rel="stylesheet" href="/static/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/layuimini.css" media="all">
    <link rel="stylesheet" href="/static/css/themes/default.css" media="all">
    <link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/css/public.css" media="all">
</head>
<body class="layui-layout-body layuimini-all">
<div class="layuimini-container">
    <div class="layuimini-main">

      <%--<fieldset class="table-search-fieldset">
            <legend>出险查询</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">报案编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="caseReportId" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">被保人</label>
                            <div class="layui-input-inline">
                                <input type="text" name="recognizeeName" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        &lt;%&ndash;<div class="layui-inline">
                            <label class="layui-form-label">车牌编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="city" autocomplete="off" class="layui-input">
                            </div>
                        </div>&ndash;%&gt;
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
--%>
        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add">新增报案信息</button>
                <%--<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>--%>
                <%-- <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="ReportDispose"> 报案处理 </button>
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="CaseReview"> 案件审核 </button>--%>
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="DispatchDispatch"> 派工调度 </button>
            </div>
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">修改</a>

            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete"  disabled="">删除</a>

           <%-- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" id="shenhe" lay-event="shenhe"  disabled="">审核</a>--%>
        </script>

    </div>
</div>
<script src="/static/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="/static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    var data ="";//表单对象值
    var caseReportid ="";
    var recognizeename ="";
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table
        table.render({
            elem: '#currentTableId',
            url: '/accident/selectAll',
            toolbar: '#toolbarDemo',
            page: true, //开启分页
            //totalRow: true, //开启合计行
            height: 620,
            cols: [[
                {field: 'caseReportId', fixed: 'left', Width: 50, title: '报案编号', sort: true},
                {field: 'warrantyId', Width: 50, title: '保单号'},
                {field: 'recognizeeName', Width: 20, title: '被保人', sort: true},
                {field: 'reportPerson', minWidth: 20, title: '报案人'},
                {field: 'caseReportTime', title: '报案时间', minWidth: 20},
                {field: 'reportPersonTel', minWidth: 20, title: '报案电话', sort: true},
                {field: 'driver', minWidth: 20, title: '司机姓名', sort: true},
                {field: 'dangerTime', minWidth: 20, title: '出现时间'},
                {field: 'province', minWidth: 20, title: '出现地点', sort: true},
                {field: 'dangerCause', minWidth: 20, title: '出险原因', sort: true},
                {field: 'jobState', minWidth: 20, title: '报案处理', sort: true},
                {field: 'claimStatus', minWidth: 20, title: '案件状态', sort: true},
                {title: '操作',  width: 165, align:'center',sort: true, fixed: 'right', toolbar: '#currentTableBar'}
            ]],
            page: true,
            limits: [20, 40, 60, 80, 100],
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                //console.log(res);
                //得到当前页码
                //console.log(curr);
                //得到数据总量
                //console.log(count);
                $(".layui-table-box").find("[data-field='id']").css("display", "none");

                $("[data-field='claimStatus']").children().each(function () {
                    if ($(this).text() == '1') {
                        $(this).text("已报案")
                    } else if ($(this).text() == '2') {
                        $(this).text("已立案")
                    } else if ($(this).text() == '3') {
                        $(this).text("已结案")
                    } else if ($(this).text() == '4') {
                        $(this).text("已撤案）")
                    }else if ($(this).text() == '0'){
                        $(this).text(" ")
                    }
                });
                $("[data-field='jobState']").children().each(function () {
                    if ($(this).text() == '1') {
                        $(this).text("待处理");
                        //$('#shenhe').button('disable');
                    } else if ($(this).text() == '2') {
                        $(this).text("接收");
                      //  $('#shenhe').button('enable');
                    } else if ($(this).text() == '3') {
                        $(this).text("暂存");
                       // $('#shenhe').button('disable');
                    } else if ($(this).text() == '4') {
                        $(this).text("已处理")
                       // $('#shenhe').button('di;sable');
                    } else if ($(this).text() == '5') {
                        $(this).text("退回");
                     //   $('#shenhe').button('disable');
                    }
                });
            }

        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '新增报案信息',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['70%', '70%'],
                    content: '/table/add',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'ReportDispose') {  // 监听添加操作
                var index = layer.open({
                    title: '报案处理',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['70%', '70%'],
                    content: '/table/ReportDispose',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'CaseReview') {  // 监听添加操作
                var index = layer.open({
                    title: '案件审核',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['70%', '70%'],
                    content: '/table/CaseReview',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'DispatchDispatch') {  // 监听添加操作
                var index = layer.open({
                    title: '派工调度',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['70%', '70%'],
                    content: '/table/DispatchDispatch',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            }/*else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }*/
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });


        table.on('tool(currentTableFilter)', function (obj) {
            data = obj.data;//获取表单对象值
            if (obj.event === 'edit') {
                var index = layer.open({
                    title: '报案处理',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['70%', '70%'],
                    content: '/table/ReportDispose',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
               /* layer.msg(data.msg, {icon:1,time:1000},function(){
                    setTimeout('window.location.reload()',1000);
                });*/
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: "/warranty/delete",
                        method: "POST",
                        contentType: "application/json;charset=utf-8",
                        data: JSON.stringify(data),
                        dataType: "json",
                        success: function (result) {
                            console.log(result);
                        }
                    });
                });

            }
        });

    });
</script>
</div>
</body>
</html>
